<?php
//获取传递过来的数据
session_start();
$id=$_GET['id'];
$title=$_GET['title'];
$price=$_GET['price'];
$jiegou=$_GET['jiegou'];
$mianji=$_GET['mianji'];
$louceng=$_GET['louceng'];
$address=$_GET['address'];
$fdname=$_GET['fdname'];
$img=$_GET['img'];

//把session中的标题信息和传过来的标题信息进行比较
$house=$_SESSION['house'];

if ($title==$house[$title][$title]){
    //买过的话，则在总价格增加，相应的商品数量增加
    //$_SESSION['znumber']+=$znumber;
    //$house[$title]['number']+=1;
    alert("你已经收藏过了");
    //不让相应的数量增加，这个页面只是显示用户收藏的房源信息
}else{
    //第一次加入收藏，将相应的房源信息添加到我们的session中
    $house[$title]['title']=$title;
    $house[$title]['price']=$price;
    $house[$title]['jiegou']=$jiegou;
    $house[$title]['mianji']=$mianji;
    $house[$title]['louceng']=$louceng;
    $house[$title]['address']=$address;
    $house[$title]['fdname']=$fdname;
    $house[$title]['img']=$img;
    //$house[$title]['number']+=1;
    //$_SESSION['totalJifen']+=$price;
}
//把所有数据转换成 SESSION
$_SESSION['house']=$house;

header('location:house.php');